/**
 * Created by hlh on 2015/8/31.
 */

export default class FundStatus {
    constructor(data) {
        this.className = 'fundStatus';
        this.sts = {
            dailySet: 'pack_fundStatus_container'
        };
        this.data = data;
    }

    render() {
        let pd = this.data;
        if (pd.status != "1") {
            return pd.msg;
        }
        let num=~~pd.sum_number;
        pd = pd.detail;
        let len = pd.length;
        for (let i = len - 1; i > 0; i--) {
            let cur = pd[i][1].split('_')[0];
            let bef = pd[i - 1][1].split('_')[0];
            if (cur === bef) {
                pd[i][1] = pd[i][1].split('_')[1];
            }
        }
        let strGenerator = function ($1, $2, $3) {
            $1=decodeURIComponent($1);
            $2=decodeURIComponent($2);
            return `
             <div class="detail_dailySet_container">
                    <div class="stock_detail_container">
                        <div class="kid_stock_time">${$1}</div><div class="kid_stock_name">${$2}</div><div class="kid_stock_num">+1元</div><div class="kid_stock_currentNum"></div>
                    </div>
                </div>
            `;
        }
        let str = "";
        for (let i = 0; i < len; i++) {
            let cur = pd[i][1].split('_');
            if (cur.length > 1) {
                str += `<div class="title_dailySet_container"><span class="dot_tile_superSize">·</span><span class="time_tile_text">${cur[0]}</span><span class="current_title_text">筹款现状</span></div>
                                ${strGenerator(cur[1], pd[i][0], num--)}
                `;
            } else if (cur.length > 0) {
                str += strGenerator(cur[0], pd[i][0], num--);
            }

        }
        return `
        <div class="${this.className}">
            <div class="${this.sts.dailySet}">
                ${str}
            </div>
        </div>`

    }

}